package com.db.stexchem.client.gui;

import javax.swing.JPanel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.JTabbedPane;

import com.db.stexchem.client.Client;

public class ClientPanel extends JPanel {

  private OrderTableModel orderTableModel;
  private OrderPanel      orderPanel;
  private ExecutionTableModel executionTableModel;
  private ExecutionPanel      executionPanel;
  private OrderEntryPanel orderEntryPanel;
  private LoginPanel loginPanel;

  /**
   * Create the panel.
   */
  public ClientPanel(OrderTableModel orderTableModel,
   ExecutionTableModel executionTableModel,
      Client application) {
    setName("BanzaiPanel");
    this.orderTableModel = orderTableModel;
    this.executionTableModel = executionTableModel;
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = GridBagConstraints.BOTH;
    constraints.weightx = 1;

    loginPanel = new LoginPanel(application);
    constraints.insets = new Insets(0, 0, 5, 0);
    ++constraints.gridy;
    add(loginPanel, constraints);
    ++constraints.gridy;
    
    orderEntryPanel = new OrderEntryPanel(orderTableModel, application);
    ++constraints.gridy;
    add(orderEntryPanel, constraints);

    ++constraints.gridy;
    constraints.weighty = 10;

    JTabbedPane tabbedPane = new JTabbedPane();
    orderPanel = new OrderPanel(orderTableModel);
    executionPanel = new ExecutionPanel(executionTableModel);
    tabbedPane.add("Orders", orderPanel);
    tabbedPane.add("Executions", executionPanel);
    add(tabbedPane, constraints);

  }

}
